package com.example.wssapp.fragment;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.wssapp.R;

public class TextFragment extends Fragment {

	private TextView textView;
	private String content;
	
	public TextFragment() {
		// 横竖品切换时，保存当前碎片实例
		setRetainInstance(true);
	}

	public TextFragment(String content) {
		this.content = content;
	}
	
	@Override
	public void onAttach(Activity activity) {
		super.onAttach(activity);
	}
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}
	
	// 渲染fragment
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {

		View v = inflater.inflate(R.layout.text_fragment, container, false);
		textView = (TextView) v.findViewById(R.id.fragmentContent);
		textView.setText(content);
		return v;
	}
	
	// father activity已经创建，如果需要访问父activity， 在这一步就可以了
	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
	}
	
	// fragment在这一步已经可见了，但是还不能和用户交互
	@Override
	public void onStart() {
		super.onStart();
	}

}
